/*
 * file:  main.h (main program to test Expr).
 * Author: Jeremy Johnson 
 * Date: 1/31/06
 *
 * Description:
 */

#include <iostream>
#include <string>
#include <map>
#include <list>
#include "program.h"

using namespace std;


int main()
{

	map<string,int> T;
	map<string,int>::iterator p;
	StmtList *SL, *SL1;
	Stmt *S1, *S2, *S3, *S4, *S5;
	Expr *E;

	S1 = new AssignStmt("i",new Number(3));
	S2 = new AssignStmt("s",new Number(0));
	S3 = new AssignStmt("s",
                   new Plus(new Ident("s"), new Ident("i")));
	S4 = new AssignStmt("i",
                   new Minus(new Ident("i"), new Number(1)));
	SL1 = new StmtList();
	SL1->insert(S4);  SL1->insert(S3);
	E = new Ident("i");

	S5 = new WhileStmt(E,SL1);

	SL = new StmtList();
	SL->insert(S5);  SL->insert(S2); SL->insert(S1);
	SL->eval(T);

	
	cout << "Testing Statement List" << endl;
	cout << "i := 3; s := 0" << endl;
	cout << "while i do s := s+i; i := i-1 od" << endl;
	cout << "Symbol Table dump" << endl;
	for (p=T.begin();p!=T.end();p++)
		cout << p->first << "," << p->second << endl;
	cout << endl;

	return 0;
}


